﻿using System;
using WorkOrder.Business;
using System.Data;

namespace WorkOrder
{
    public partial class taskreport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (Session["UserID"] == null || Session["UserID"].ToString() == "")
            //{
            //    Session.Clear();
            //    ClientScript.RegisterClientScriptBlock(this.GetType(), "windowhref", "<script type='text/javascript'>alert('对不起，您还没有登录系统！');window.parent.location.href='../login.aspx';</script>");
            //}
        }

        protected void btnSearch_ServerClick(object sender, EventArgs e)
        {
            if (txtStart.Value.Trim() != "" && txtEnd.Value.Trim() != "")
            {
                FillData();
            }
        }

        private void FillData()
        {
            TaskReport tr = new TaskReport();
            DataTable tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17;
            tmp1 = tr.getSumOfNew(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp2 = tr.getHasProjectOfNew(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp3 = tr.getHasNotProjectOfNew(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp4 = tr.getHasProjectOfModify(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp5 = tr.getHasNotProjectOfModify(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp6 = tr.getSumOfModify(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp9 = tr.getHasProjectOfNewTimeout(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp10 = tr.getHasNotProjectOfNewTimeout(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp11 = tr.getHasProjectOfModifyTimeout(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp12 = tr.getHasNotProjectOfModifyTimeout(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp13 = tr.getSumOfCancel(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp14 = tr.getHasProjectOfCancel(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp15 = tr.getHasProjectOfCancelTimeout(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp16 = tr.getHasNotProjectOfCancel(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tmp17 = tr.getHasNotProjectOfCancelTimeout(txtStart.Value.Trim(), txtEnd.Value.Trim());
            //tmp19 = tr.getAvgTimeOfCancel(txtStart.Value.Trim(), txtEnd.Value.Trim());
            int tmpInt1 = 0, tmpInt2 = 0, tmpInt3 = 0, tmpInt4 = 0, tmpInt5 = 0, tmpInt6 = 0, tmpInt7 = 0, tmpInt8 = 0, tmpInt9 = 0, tmpInt10 = 0, tmpInt16 = 0, tmpInt17 = 0, tmpInt18 = 0, tmpInt14 = 0, tmpInt15 = 0;

            #region 第一个表tab1 开通单
            tab1.Rows[7].Cells[1].InnerText = "0";
            tab1.Rows[7].Cells[2].InnerText = "0";
            tab1.Rows[7].Cells[3].InnerText = "0";
            tab1.Rows[7].Cells[4].InnerText = "0";
            tab1.Rows[7].Cells[5].InnerText = "0";
            tab1.Rows[7].Cells[6].InnerText = "0";
            for (int i = 1; i <= 6; i++)
            {
                #region 先将所有单元格填0
                tab1.Rows[i].Cells[1].InnerText = "0";
                tab1.Rows[i].Cells[2].InnerText = "0";
                tab1.Rows[i].Cells[3].InnerText = "0";
                tab1.Rows[i].Cells[4].InnerText = "0";
                tab1.Rows[i].Cells[5].InnerText = "0";
                tab1.Rows[i].Cells[6].InnerText = "0";
                #endregion

                #region 填充数据
                
                #region 有工程及时单
                for (int j = 0; j < tmp2.Rows.Count; j++)
                {

                    if (tab1.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp2.Rows[j][0].ToString())
                    {
                        tab1.Rows[i].Cells[1].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=1&p=" + tmp2.Rows[j][2].ToString()
                        + "&j=1&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp2.Rows[j][1].ToString() + "</a>";
                        tab1.Rows[i].Cells[1].Attributes.Add("datavlaue",tmp2.Rows[j][1].ToString());
                        
                        tmpInt1 = tmpInt1 + Convert.ToInt32(tmp2.Rows[j][1]);
                    }
                }
                #endregion

                #region 无工程及时单
                for (int j = 0; j < tmp3.Rows.Count; j++)
                {
                    if (tab1.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp3.Rows[j][0].ToString())
                    {
                        tab1.Rows[i].Cells[2].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=1&p=" + tmp3.Rows[j][2].ToString()
                        + "&j=1&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp3.Rows[j][1].ToString() + "</a>";
                        tab1.Rows[i].Cells[2].Attributes.Add("datavlaue", tmp3.Rows[j][1].ToString());
                        
                        tmpInt2 = tmpInt2 + Convert.ToInt32(tmp3.Rows[j][1]);
                    }
                }
                #endregion

                #region 总量
                for (int j = 0; j < tmp1.Rows.Count; j++)
                {
                    if (tab1.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp1.Rows[j][0].ToString())
                    {
                        tab1.Rows[i].Cells[5].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=1&p=" + tmp1.Rows[j][2].ToString()
                        + "&j=2&e=2&v=','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp1.Rows[j][1].ToString() + "</a>";
                        tab1.Rows[i].Cells[5].Attributes.Add("datavlaue", tmp1.Rows[j][1].ToString());
                        
                        tmpInt3 = tmpInt3 + Convert.ToInt32(tmp1.Rows[j][1]);
                    }
                }
                #endregion

                #region 有工程超时单
                for (int j = 0; j < tmp9.Rows.Count; j++)
                {
                    if (tab1.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp9.Rows[j][0].ToString())
                    {
                        tab1.Rows[i].Cells[3].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=1&p=" + tmp9.Rows[j][2].ToString()
                        + "&j=0&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp9.Rows[j][1].ToString() + "</a>";
                        tmpInt7 = tmpInt7 + Convert.ToInt32(tmp9.Rows[j][1]);
                    }
                }
                #endregion

                #region 无工程超时单
                for (int j = 0; j < tmp10.Rows.Count; j++)
                {
                    if (tab1.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp10.Rows[j][0].ToString())
                    {
                        tab1.Rows[i].Cells[4].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=1&p=" + tmp10.Rows[j][2].ToString()
                        + "&j=0&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp10.Rows[j][1].ToString() + "</a>";
                        tmpInt8 = tmpInt8 + Convert.ToInt32(tmp10.Rows[j][1]);
                    }
                }
                #endregion

                if (tab1.Rows[i].Cells[5].InnerText != "0")
                    tab1.Rows[i].Cells[6].InnerText = Math.Round(Math.Round((decimal)(Convert.ToInt32(tab1.Rows[i].Cells[1].Attributes["datavlaue"]) +
                        Convert.ToInt32(tab1.Rows[i].Cells[2].Attributes["datavlaue"])) / (decimal)Convert.ToInt32(tab1.Rows[i].Cells[5].Attributes["datavlaue"]), 4) * 100, 2).ToString() + "%";

                #endregion
            }

            #region 填充总计
            tab1.Rows[7].Cells[1].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=1&p=C"
                        + "&j=1&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt1.ToString() + "</a>";
            tab1.Rows[7].Cells[2].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=1&p=C"
                        + "&j=1&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt2.ToString() + "</a>";
            tab1.Rows[7].Cells[3].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=1&p=C"
                        + "&j=0&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt7.ToString() + "</a>";
            tab1.Rows[7].Cells[4].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=1&p=C"
                        + "&j=0&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt8.ToString() + "</a>"; 
            tab1.Rows[7].Cells[5].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=1&p=C"
                        + "&j=2&e=2&v=','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt3.ToString() + "</a>";
            if (tmpInt3!=0) tab1.Rows[7].Cells[6].InnerText = Math.Round(Math.Round((decimal)(tmpInt1 + tmpInt2) / (decimal)tmpInt3, 4) * 100, 2).ToString() + "%";
            #endregion 

            #endregion

            #region 第二个表tab2 调整单
            tab2.Rows[7].Cells[1].InnerText = "0";
            tab2.Rows[7].Cells[2].InnerText = "0";
            tab2.Rows[7].Cells[3].InnerText = "0";
            tab2.Rows[7].Cells[4].InnerText = "0";
            tab2.Rows[7].Cells[5].InnerText = "0";
            tab2.Rows[7].Cells[6].InnerText = "0";
            for (int i = 1; i <= 6; i++)
            {
                #region 先将所有单元格填0
                tab2.Rows[i].Cells[1].InnerText = "0";
                tab2.Rows[i].Cells[2].InnerText = "0";
                tab2.Rows[i].Cells[3].InnerText = "0";
                tab2.Rows[i].Cells[4].InnerText = "0";
                tab2.Rows[i].Cells[5].InnerText = "0";
                tab2.Rows[i].Cells[6].InnerText = "0";
                #endregion

                #region 填充数据
                #region 有工程及时单
                for (int j = 0; j < tmp4.Rows.Count; j++)
                {

                    if (tab2.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp4.Rows[j][0].ToString())
                    {
                        tab2.Rows[i].Cells[1].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=3&p=" + tmp4.Rows[j][2].ToString()
                        + "&j=1&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp4.Rows[j][1].ToString() + "</a>";
                        tab2.Rows[i].Cells[1].Attributes.Add("datavlaue", tmp4.Rows[j][1].ToString());
                        tmpInt4 = tmpInt4 + Convert.ToInt32(tmp4.Rows[j][1]);
                    }
                }
                #endregion 

                #region 无工程及时单
                for (int j = 0; j < tmp5.Rows.Count; j++)
                {
                    if (tab2.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp5.Rows[j][0].ToString())
                    {
                        tab2.Rows[i].Cells[2].InnerHtml = tmp5.Rows[j][1].ToString();
                        tab2.Rows[i].Cells[2].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=3&p=" + tmp5.Rows[j][2].ToString()
                        + "&j=1&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp5.Rows[j][1].ToString() + "</a>";
                        tab2.Rows[i].Cells[2].Attributes.Add("datavlaue", tmp5.Rows[j][1].ToString());
                        tmpInt5 = tmpInt5 + Convert.ToInt32(tmp5.Rows[j][1]);
                    }
                }
                #endregion

                #region 总量
                for (int j = 0; j < tmp6.Rows.Count; j++)
                {
                    if (tab2.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp6.Rows[j][0].ToString())
                    {
                        tab2.Rows[i].Cells[5].InnerHtml = tmp6.Rows[j][1].ToString();
                        tab2.Rows[i].Cells[5].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=3&p=" + tmp6.Rows[j][2].ToString()
                        + "&j=2&e=2&v=','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp6.Rows[j][1].ToString() + "</a>";
                        tab2.Rows[i].Cells[5].Attributes.Add("datavlaue", tmp6.Rows[j][1].ToString());
                        tmpInt6 = tmpInt6 + Convert.ToInt32(tmp6.Rows[j][1]);
                    }
                }
                #endregion

                 #region 有工程超时单
                for (int j = 0; j < tmp11.Rows.Count; j++)
                {
                    if (tab2.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp11.Rows[j][0].ToString())
                    {
                        tab2.Rows[i].Cells[3].InnerHtml = tmp11.Rows[j][1].ToString();
                        tab2.Rows[i].Cells[3].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=3&p=" + tmp11.Rows[j][2].ToString()
                        + "&j=0&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp11.Rows[j][1].ToString() + "</a>";
                        tmpInt9 = tmpInt9 + Convert.ToInt32(tmp11.Rows[j][1]);
                    }
                }
                #endregion

                #region 无工程超时单
                for (int j = 0; j < tmp12.Rows.Count; j++)
                {
                    if (tab2.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp12.Rows[j][0].ToString())
                    {
                        tab2.Rows[i].Cells[4].InnerHtml = tmp12.Rows[j][1].ToString();
                        tab2.Rows[i].Cells[4].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=3&p=" + tmp12.Rows[j][2].ToString()
                        + "&j=0&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp12.Rows[j][1].ToString() + "</a>";
                        tmpInt10 = tmpInt10 + Convert.ToInt32(tmp12.Rows[j][1]);
                    }
                }
                #endregion

                if (tab2.Rows[i].Cells[5].InnerText != "0")
                    tab2.Rows[i].Cells[6].InnerText = Math.Round(Math.Round((decimal)(Convert.ToInt32(tab2.Rows[i].Cells[1].Attributes["datavlaue"]) +
                        Convert.ToInt32(tab2.Rows[i].Cells[2].Attributes["datavlaue"])) / (decimal)Convert.ToInt32(tab2.Rows[i].Cells[5].Attributes["datavlaue"]), 4) * 100, 2).ToString() + "%";

                #endregion
            }
            #region 填充总计
            tab2.Rows[7].Cells[1].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=3&p=C"
                        + "&j=1&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt4.ToString() + "</a>";
            tab2.Rows[7].Cells[2].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=3&p=C"
                        + "&j=1&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt5.ToString() + "</a>";
            tab2.Rows[7].Cells[3].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=3&p=C"
                        + "&j=0&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt9.ToString() + "</a>";
            tab2.Rows[7].Cells[4].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=3&p=C"
                        + "&j=0&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt10.ToString() + "</a>";
            tab2.Rows[7].Cells[5].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=3&p=C"
                        + "&j=2&e=2&v=','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt6.ToString() + "</a>"; 
            if (tmpInt6!=0) tab2.Rows[7].Cells[6].InnerText = Math.Round(Math.Round((decimal)(tmpInt4 + tmpInt5) / (decimal)tmpInt6, 4) * 100, 2).ToString() + "%";
            #endregion
            #endregion 

            #region 第五个表tab5 取消单
            tab5.Rows[7].Cells[1].InnerText = "0";
            tab5.Rows[7].Cells[2].InnerText = "0";
            tab5.Rows[7].Cells[3].InnerText = "0";
            tab5.Rows[7].Cells[4].InnerText = "0";
            tab5.Rows[7].Cells[5].InnerText = "0";
            tab5.Rows[7].Cells[6].InnerText = "0";
            for (int i = 1; i <= 6; i++)
            {
                #region 先将所有单元格填0
                tab5.Rows[i].Cells[1].InnerText = "0";
                tab5.Rows[i].Cells[2].InnerText = "0";
                tab5.Rows[i].Cells[3].InnerText = "0";
                tab5.Rows[i].Cells[4].InnerText = "0";
                tab5.Rows[i].Cells[5].InnerText = "0";
                tab5.Rows[i].Cells[6].InnerText = "0";
                #endregion

                #region 填充数据
                #region 有工程及时单
                for (int j = 0; j < tmp14.Rows.Count; j++)
                {

                    if (tab5.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp14.Rows[j][0].ToString())
                    {
                        tab5.Rows[i].Cells[1].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=2&p=" + tmp14.Rows[j][2].ToString()
                        + "&j=1&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp14.Rows[j][1].ToString() + "</a>";
                        tab5.Rows[i].Cells[1].Attributes.Add("datavlaue", tmp14.Rows[j][1].ToString());
                        tmpInt14 = tmpInt14 + Convert.ToInt32(tmp14.Rows[j][1]);
                    }
                }
                #endregion

                #region 无工程及时单
                for (int j = 0; j < tmp16.Rows.Count; j++)
                {
                    if (tab5.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp16.Rows[j][0].ToString())
                    {
                        tab5.Rows[i].Cells[2].InnerHtml = tmp16.Rows[j][1].ToString();
                        tab5.Rows[i].Cells[2].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=2&p=" + tmp16.Rows[j][2].ToString()
                        + "&j=1&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp16.Rows[j][1].ToString() + "</a>";
                        tab5.Rows[i].Cells[2].Attributes.Add("datavlaue", tmp16.Rows[j][1].ToString());
                        tmpInt15 = tmpInt15 + Convert.ToInt32(tmp16.Rows[j][1]);
                    }
                }
                #endregion

                #region 总量
                for (int j = 0; j < tmp13.Rows.Count; j++)
                {
                    if (tab5.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp13.Rows[j][0].ToString())
                    {
                        tab5.Rows[i].Cells[5].InnerHtml = tmp13.Rows[j][1].ToString();
                        tab5.Rows[i].Cells[5].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=2&p=" + tmp13.Rows[j][2].ToString()
                        + "&j=2&e=2&v=','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp13.Rows[j][1].ToString() + "</a>";
                        tab5.Rows[i].Cells[5].Attributes.Add("datavlaue", tmp13.Rows[j][1].ToString());
                        tmpInt16 = tmpInt16 + Convert.ToInt32(tmp13.Rows[j][1]);
                    }
                }
                #endregion

                #region 有工程超时单
                for (int j = 0; j < tmp15.Rows.Count; j++)
                {
                    if (tab5.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp15.Rows[j][0].ToString())
                    {
                        tab5.Rows[i].Cells[3].InnerHtml = tmp15.Rows[j][1].ToString();
                        tab5.Rows[i].Cells[3].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=2&p=" + tmp15.Rows[j][2].ToString()
                        + "&j=0&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp15.Rows[j][1].ToString() + "</a>";
                        tmpInt17 = tmpInt17 + Convert.ToInt32(tmp15.Rows[j][1]);
                    }
                }
                #endregion

                #region 无工程超时单
                for (int j = 0; j < tmp17.Rows.Count; j++)
                {
                    if (tab5.Rows[i].Cells[0].InnerText.Trim().Replace("\r\n", "").Trim() == tmp17.Rows[j][0].ToString())
                    {
                        tab5.Rows[i].Cells[4].InnerHtml = tmp17.Rows[j][1].ToString();
                        tab5.Rows[i].Cells[4].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=2&p=" + tmp17.Rows[j][2].ToString()
                        + "&j=0&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmp17.Rows[j][1].ToString() + "</a>";
                        tmpInt18 = tmpInt18 + Convert.ToInt32(tmp17.Rows[j][1]);
                    }
                }
                #endregion

                if (tab5.Rows[i].Cells[5].InnerText != "0")
                    tab5.Rows[i].Cells[6].InnerText = Math.Round(Math.Round((decimal)(Convert.ToInt32(tab5.Rows[i].Cells[1].Attributes["datavlaue"]) +
                        Convert.ToInt32(tab5.Rows[i].Cells[2].Attributes["datavlaue"])) / (decimal)Convert.ToInt32(tab5.Rows[i].Cells[5].Attributes["datavlaue"]), 4) * 100, 2).ToString() + "%";

                #endregion
            }
            #region 填充总计
            tab5.Rows[7].Cells[1].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=2&p=C"
                        + "&j=1&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt14.ToString() + "</a>";
            tab5.Rows[7].Cells[2].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=2&p=C"
                        + "&j=1&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt15.ToString() + "</a>";
            tab5.Rows[7].Cells[3].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=2&p=C"
                        + "&j=0&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt17.ToString() + "</a>";
            tab5.Rows[7].Cells[4].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=2&p=C"
                        + "&j=0&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt18.ToString() + "</a>";
            tab5.Rows[7].Cells[5].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=2&p=C"
                        + "&j=2&e=2&v=','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tmpInt16.ToString() + "</a>";
            if (tmpInt16!=0) tab5.Rows[7].Cells[6].InnerText = Math.Round(Math.Round((decimal)(tmpInt14 + tmpInt15) / (decimal)tmpInt16, 4) * 100, 2).ToString() + "%";
            #endregion
            #endregion

            #region 总计表格
            int a, b, c;
            a = tr.getSumHasEn(txtStart.Value.Trim(), txtEnd.Value.Trim());
            b = tr.getSumHasNotEn(txtStart.Value.Trim(), txtEnd.Value.Trim());
            c = tr.getSum(txtStart.Value.Trim(), txtEnd.Value.Trim());
            tab4.Rows[1].Cells[0].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=A&p=C"
                        + "&j=1&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + a.ToString() + "</a>";
            tab4.Rows[1].Cells[1].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=A&p=C"
                        + "&j=1&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + b.ToString() + "</a>";
            tab4.Rows[1].Cells[2].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=A&p=C"
                        + "&j=0&e=1&v=40','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tr.getSumHasEnTimeout(txtStart.Value.Trim(), txtEnd.Value.Trim()).ToString() + "</a>";
            tab4.Rows[1].Cells[3].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=A&p=C"
                        + "&j=0&e=0&v=10$7','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + tr.getSumHasNotEnTimeout(txtStart.Value.Trim(), txtEnd.Value.Trim()).ToString() + "</a>";
            tab4.Rows[1].Cells[4].InnerHtml = "<a href=\"#\" title=\"点击查看工单列表\" onclick=\"window.open('taskReportList.aspx?f="
                        + txtStart.Value + "&t=" + txtEnd.Value + "&o=A&p=C"
                        + "&j=2&e=2&v=','','location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600');\">"
                        + c.ToString() + "</a>";
            if (c != 0)
                tab4.Rows[1].Cells[5].InnerText = Math.Round(Math.Round((decimal)(a + b) / (decimal)(c), 4) * 100, 2).ToString() + "%";
            
            #endregion 

            
        }
        
    }
}
